﻿using DevelopmentKit.Cms.Domain;
using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;

namespace DevelopmentKit.Cms.Infrastructure.NHibernateMaps
{
    /// <summary>
    /// 内容映射
    /// </summary>
    public class ContentMap : IAutoMappingOverride<Content>
    {
        public void Override(AutoMapping<Content> mapping)
        {
            mapping.IgnoreProperty(x => x.Details);
            mapping.HasMany(x => x.ContentDetails).Cascade.AllDeleteOrphan();
            mapping.References(x => x.Parent).Column("ParentId");
            mapping.HasMany(x => x.Children).KeyColumn("ParentId");
        }
    }
}